<template>
  <div class="app-container">
    医生审核列表
    <el-table
      :data="this.list" stripe style="width: 100%">
      <el-table-column type="index" width="50" label="序号"/>
      <el-table-column prop="docName" label="医生姓名"/>
      <el-table-column prop="docHos" label="医院"/>
      <el-table-column prop="docDep" label="科室"/>
      <el-table-column prop="skill" label="擅长"/>
      <el-table-column prop="phone" label="电话"/>
      <el-table-column prop="note" label="备注"/>
      <el-table-column label="图片">
        <template slot-scope="scope">
        <img
          style="width: 100px; height: 100px"
          :src="'data:image/jpeg;base64,'+scope.row.image"
          :fit="fit">
        </template>
      </el-table-column>
      <el-table-column label="操作" width="280" align="center">
        <template slot-scope="scope">
          <el-button v-if="scope.row.status == 0"  type="primary" size="mini" @click="updateStatus(scope.row.id)">下线</el-button>
          <el-button v-if="scope.row.status == 1"  type="danger" size="mini" @click="updateStatus(scope.row.id)">上线</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import doc from '@/api/doctor'

export default {
  data() {
    return {
      current: 1, //当前页
      limit: 3, //每页显示记录数
      searchObj: {}, //条件封装对象
      list: [], //每页数据集合
      total: 0,//总记录数
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {//添加当前页参数
      doc.getList()
        .then(response => {//接口返回数据
//返回集合list
          this.list = response.data
          console.log(this.list)
        })//请求成功
        .catch(error => {//请求失败
          console.log(error)
        })
    },
    removeDataById(id) {
      this.$confirm('此操作将永久删除设置信息, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        doc.remove(id).then(response => {
//提示信息
          this.$message({

            type: 'success',
            message: '删除成功!'
          })
          this.getList()
        })
      })
    },
    updateStatus(id){
      doc.updateStatus(id)
        .then(response=>{
          this.getList()
        })
    },
  }
}
</script>
